<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <base target="_self"/>
    <link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=path %>/jqGrid/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <c:if test="${requestScope.message!=null}">
		<script type="text/javascript">
 	 		     alert('<c:out value="${requestScope.message}"></c:out>');
 	 		     window.close();
 		</script>
	</c:if>
	
    <script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    var stateValue="";
    $().ready(function(){
    	//selectSccj();
    	selectGys();
			var options = {
		  	    url:'<%=request.getContextPath() %>/eqAction!saveHeTongEXEC.action?sx_id='+$('#sx_id').val()+'&equHtId='+${requestScope.equHtId}+'&equMainId=${requestScope.equMainId}',
		  	     beforeSubmit: function() {
		   				return checking();
		    			},
		  	    dataType:'json',
		  	    success: function(data) {
		  	      if(data.result=='success'){
					alert("添加成功");
					api.close();
					W.reload();
		  	      }
		  	    }};
		$('#saveBtn').click(function(){
			    	$('#pageFrom').ajaxSubmit(options);
	 	            return false;
    	 });
    	$('#closeBtn').click(function(){
    		api.close();
		});
		
	});
	
   	function checking(){
   		var flag = true;
		var equipmentHtno = $.trim($("#equipmentHtno").val());
		var equipmentZbqsrq = $.trim($("#equipmentZbqsrq").val());
		var equipmentZbjsrq = $.trim($("#equipmentZbjsrq").val());
		var equipmentSbsx = $.trim($("#equipmentSbsx").val());
		var equipmentJkzb = $.trim($("#equipmentJkzb").val());
		if(equipmentHtno ==null || equipmentHtno == "" ){
			alert("合同编号不能为空！");
			$("#equipmentHtno").focus();
    		return false;
		}
		if(equipmentZbqsrq ==null || equipmentZbqsrq == "" ){
			alert("请选择质量保证期起始日期！");
			$("#equipmentZbqsrq").focus();
    		return false;
		}
		if(equipmentZbjsrq ==null || equipmentZbjsrq == "" ){
			alert("质量保证期结束日期！");
			$("#equipmentZbjsrq").focus();
    		return false;
		}
		if(equipmentSbsx ==null || equipmentSbsx == "" ){
			alert("设备属性不能为空！");
			$("#equipmentSbsx").focus();
    		return false;
		}
		if(equipmentJkzb ==null || equipmentJkzb == "" ){
			alert("监控指标不能为空！");
			$("#equipmentJkzb").focus();
    		return false;
		}
	}
	 
	function checkExp(inputData){ 
		var regEx = new RegExp(/^(([^\^\.<>%&',:;=?$"'#@!~\]\[{}【】￥（）！·‘’”“。，、？：；—|\/\\/`\|])*)$/);
		var result = inputData.match(regEx);
		if (result == null) {
			return false;
		}
		return true;
	}
	function checkNum(inputData){
		var sNumber;
	    sNumber=Number(inputData);
	    if (isNaN(inputData)){
	       return false;
	     }
	    return true;
	}
	function countlen1(textarea){
	       var elem = event.relatedTarget || event.srcElement || event.target ||event.currentTarget;    
	        if(event.keyCode!=8)
			{
			  if (textarea.value.length> 249){
			        alert("最多为250个字符,字符输入超出限制!");
			        textarea.value=textarea.value.substring(0,249);
			    }
			    return true;
	 	    }
	}
		
	 function selectSccj(){
		jQuery.post("eqAction!getSccj.action",
				{"type" : "notall"},
				callSccj,
				"json");
	 }
	 function callSccj(json){
		 $("#equipmentSccj").empty();
			var html = ''; //<option value="">--请选择--</option>
			  $('#equipmentSccj').append(html);
			if(json!=''){
			$.each(json,function(entryindex,entry){
				html = '<option value="'+entry['id']+'">' + entry['name'] + '</option>';
				$('#equipmentSccj').append(html);
			});
		}
	 }
		 
	function selectGys(){
		jQuery.post("eqAction!getGongys.action",
				{"type" : "notall"},
				callGys,
				"json");
	 }
	 function callGys(json){
		 $("#equipmentGys").empty();
			var html = ''; //<option value="">--请选	择--</option>
			  $('#equipmentGys').append(html);
			if(json!=''){
			$.each(json,function(entryindex,entry){
				html = '<option value="'+entry['id']+'">' + entry['name'] + '</option>';
				$('#equipmentGys').append(html);
			});
		}
	 }
	  //选择设备属性
	function selectsbsx(id){
		var datas = window.showModalDialog("<%=request.getContextPath() %>/view/choose_equipment_sbsx.jsp?temp="+Math.round(Math.random()*10000),'',"dialogWidth=900px;dialogHeight=550px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("equipmentSbsx").value = json1.SB_SHUXING;
			 document.getElementById("sx_id").value = json1.id;
		}
	}

   </script>
 	<style type="text/css">
 		body{
 			background:#ffffff; background-image:url(images/);
 		}
   		html{
		    overflow-x: hidden;
			overflow-y: hidden;
		}  	
		.formTableNew textarea{border: 1px solid #999;padding: 5px;width: 760px;-moz-border-radius: 3px;border-radius: 3px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;}
   </style>
  </head>
  
  <body>
<form id="pageFrom" action="" enctype="multipart/form-data" method="post">
        <input type="hidden" id="flag" name="flag" />
  		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="5" class="formTableNew">
  		<input id="equMainId" type="hidden" name="equMainId" value="${requestScope.equMainId}"/>
  		<input id="equHtId" type="hidden" name="equHtId" value="${requestScope.equHtId}"/>
  			<tr>
  			  <td align="right">合同编号：</td>
  			  <td align="left">
  			    <input  type="text"  id="equipmentHtno" maxlength="50" name="equipmentHtno" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  <!-- 
  			  <td align="right">生产厂家：</td>
  			  <td align="left">
  			  	 <select   name="equipmentSccj" id="equipmentSccj" class='fselect' class='easyui-validatebox'   style="border: 1px solid #999;padding: 5px;width: 250px;height:40px;" onkeydown="if(event.keyCode==8)return false;"></select>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			   -->
  			  
  			</tr>
  			<tr>
  			  <td align="right">供应商：</td>
  			  <td align="left">
  			  	 <select   name="equipmentGys" id="equipmentGys" class='fselect' class='easyui-validatebox'  style="border: 1px solid #999;padding: 5px;width: 250px;height:40px;" onkeydown="if(event.keyCode==8)return false;"></select>
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">质量保证期起始日期：</td>
  			  <td align="left">
  			    <input  type="text"  id="equipmentZbqsrq" maxlength="50" name="equipmentZbqsrq" onClick="WdatePicker({maxDate:'#F{$dp.$D(\'equipmentZbjsrq\');}'})" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">质量保证期结束日期：</td>
  			  <td align="left">
  			    <input  type="text"  id="equipmentZbjsrq" maxlength="50" name="equipmentZbjsrq" onClick="WdatePicker({minDate:'#F{$dp.$D(\'equipmentZbqsrq\');}'})" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
		    <td align="right" >设备属性：</td>
		    <td colspan="3">
		    	<div class="div">
					<textarea rows="4" cols="100" readonly id="equipmentSbsx" name="equipmentSbsx" onkeydown="countlen1(this);" style="width: 250px;">${fixedAssets.remark }</textarea>
					<input type="hidden" id="sx_id" name="sx_id" value=""/>
	  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
	  			  	<img src="/gwm/web/images/form_icon_1.gif" style="cursor:hand; vertical-align: middle;" onclick="selectsbsx(sx_id)" />
				</div>	
		    </td>
		  </tr>
  			<tr>
		    <td align="right" >监控指标：</td>
		    <td colspan="3">
		    	<div class="div">
					<textarea rows="4" cols="100" id="equipmentJkzb" name="equipmentJkzb" onkeydown="countlen1(this);" style="width: 250px;">${fixedAssets.remark }</textarea>
					<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
				</div>	
		    </td>
		  </tr>
 			<tr>
		    <td align="right">监控指标（3年）附件：</td>
		    <td align="left">
		    	<jsp:include page="../fileupload/attachment.jsp?id=${requestScope.equHtId}&column=equipmentJkzbFile&show=n" ></jsp:include>
		    </td>
		  </tr>
		</table>
		<table width="100%" border="0" align="center" class="formTableNew">
		  <tr>
			<td align="center">
		    	<input id="saveBtn" type="button" value="提 交" class="form_bt_orange" />
		    	<input type="button" id="closeBtn" value="取 消" class="form_bt_grey" />
		    </td>
		  </tr>
		</table>
	<!--表单结束-->
	</form>
  </body>
</html>
